<?php
include('cfg/def.php');
include('cfg/cfg.php');

include_once('lib/mysql.class.php');
include_once('lib/timer.class.php');
include_once('models/parser.class.php');

// header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain; charset=utf-8');

$timer = new Timer();
$timer->start();

$parser = new Parser();
$companies = $parser->load_data();

$files = scandir("data");

foreach($files as $file)
{
	if(is_dir($file)) continue;
	
	$letter = get_text($file);
	
	$sms = $parser->parse_letter($letter);
	echo $sms["text"];
	
	/*
	echo "\n";
	echo '<pre>';
	foreach($parser->get_messages() as $msg)
	{
		echo '<a href="data/'.$file.'">';
		echo $msg;
		echo '</a><br/>';
		// echo "\n";
	}
	echo '</pre>';
	echo "\n\n";
	*/
}

echo "Executing time is ".$timer->stop()." seconds";

function get_text($fname)
{
	$fdata = file_get_contents("data/".$fname);
	return $fdata;
}


